﻿using Microsoft.Playwright;
using Newtonsoft.Json.Linq;
using OnlineStore.Common;
using System;
using System.Threading.Tasks;

namespace OnlineStore
{
    public class TianMaoPlayer : Player
    {
        public TianMaoPlayer(PlayerTask playerTask, ExecuteStatus status) : base(playerTask, status) { }

        public override async Task Execute(IBrowser browser)
        {
            try
            {
                await new TianMaoReceiver(this).Execute(browser);
            }
            catch (System.Exception e)
            {
                await Console.Out.WriteLineAsync(e.Message);
            }
            finally
            {
                ParseFile.WriteListToFile(this.TitlePath, this.TitleList);
            }
        }
    }
}
